<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@ page import="java.util.*"%>
<%@ page import="forum.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String username = (String) request.getSession().getAttribute(
			"username");
	Boolean isModerator = (Boolean) request.getSession().getAttribute(
			"isModerator");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Refresh" content="30">
<base href="<%=basePath%>">
<title>Threads list</title>
</head>
<body>

	<h2>Threads list</h2>
	<%
		List<forum.Thread> threadsList = (ArrayList) request
				.getAttribute("threads");

		for (forum.Thread t : threadsList) {
	%>
	<hr>
	<br>
	<%=t.getAuthor()%>
	posted at
	<%=t.getRoot().getDate()%>
	<br>
	<b>Subject: </b><%=t.getRoot().getSubject()%>
	<br>
	<b>Content: </b><%=t.getRoot().getContent()%>
	<br>
	<%
		out.println("<a href=\"viewThreadsProcessor?do=show&id="
					+ t.getID() + "\">Show</a>");

			if (t.getAuthor().equalsIgnoreCase(username)
					|| (isModerator != null && isModerator.booleanValue()))
				out.println("&nbsp &nbsp &nbsp <a href=\"viewThreadsProcessor?do=delete&id="
						+ t.getID()
						+ "&author="
						+ t.getAuthor()
						+ "\">Delete</a>");
		}
	%>
	<br>
	<hr>
	<%
		out.println("<a href=\"viewThreadsProcessor?do=add\">Add a new thread</a>");
	%>
	<br>
	<br>

	<a href="viewFriends">Show friends</a>
	<br>
	<a href="viewForums">Back to Forums</a>
	<br>
	<a href="logout">logout</a>

</body>
</html>